<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>发表评论</title>

		<link href="/Public/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="/Public/assets/css/amazeui.css" rel="stylesheet" type="text/css">

		<link href="/Public/css/personal.css" rel="stylesheet" type="text/css">
		<link href="/Public/css/appstyle.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="/Public/js/jquery-1.7.2.min.js"></script>
		<script src="/Public/assets/js/jquery.min.js"></script>
		<script src="/Public/assets/js/amazeui.min.js"></script>
		<!-- 引用控制层插件样式 -->
		<link rel="stylesheet" href="/Public/tools/php_img_upload/control/css/zyUpload.css" type="text/css">
	</head>

	<body>
		<!--头 -->
		<header>
			<article>
				<div class="mt-logo">
					<!--顶部导航条 -->
					<include file="./Application/Home/View/Share/header.html" />
				</div>
			</article>
		</header>
            <div class="nav-table">
					   <div class="long-title"><span class="all-goods">全部分类</span></div>
					   <div class="nav-cont">
							<ul>
								<li class="index"><a href="#">首页</a></li>
                                <li class="qc"><a href="#">闪购</a></li>
                                <li class="qc"><a href="#">限时抢</a></li>
                                <li class="qc"><a href="#">团购</a></li>
                                <li class="qc last"><a href="#">大包装</a></li>
							</ul>
						    <div class="nav-extra">
						    	<i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的福利
						    	<i class="am-icon-angle-right" style="padding-left: 10px;"></i>
						    </div>
						</div>
			</div>
			<b class="line"></b>
		<div class="center">
			<div class="col-main">
				<div class="main-wrap">

					<div class="user-comment">
						<!--标题 -->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">发表评论</strong> / <small>Make&nbsp;Comments</small></div>
						</div>
						<hr/>

						<div class="comment-main">
							<volist name="list" id="vo">
								<if condition="($vo[i].status eq 0)  ">
									<div class="comment-list">
										<div class="item-pic">
											<a href="#" class="J_MakePoint">
												<img src="{$vo.head_img}" class="itempic">
											</a>
										</div>

										<div class="item-title">

											<div class="item-name">
												<a href="#">
													<p class="item-basic-info">{$vo.ware_name}</p>
												</a>
											</div>
											<div class="item-info">
												<div class="info-little">
													<span>{$vo.ware_cart}:{$vo.cart_list}</span>
												</div>
												<div class="item-price">
													价格：<strong>{$vo.price}</strong>
												</div>										
											</div>
										</div>
										<div class="clear"></div>
										<div class="item-comment">
											<textarea class="content" placeholder="请写下对宝贝的感受吧，对他人帮助很大哦！"></textarea>
										</div>
										<div class="filePic">
											<button type="button" class="am-btn am-btn-primary am-topbar-btn am-btn-sm" onclick="modal(this);" value="{$vo.id}">图片上传</button>
											<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
												<div class="am-modal-dialog" style="width:750px;">
													<a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
													
													<div id="demo" class="demo"></div>   
													<div id="successinfo">
													<input type="hidden" class="phwareid" value="">
													</div>
													
													<div class="am-modal-bd">
												  
													</div>
												</div>
											</div>
										</div>
										<div class="item-opinion">
											<input type="hidden" class="good" name="good" value="">
											<li><i class="op1"></i>好评</li>
											<li><i class="op2"></i>中评</li>
											<li><i class="op3"></i>差评</li>
										</div>
										<div class="info-btn">
											<input type="hidden" class="id" value="{$vo.id}">
											<input type="hidden" class="wareid" value="{$vo.ware_id}">
											<a onclick="commentbtn(this);" class="am-btn am-btn-danger">发表评论</a>
										</div>	
									</div>
									<br>
								</if>
							</volist>
												
													
					<script type="text/javascript">
						$(document).ready(function() {
							$(".comment-list .item-opinion li").click(function() {	
								$(this).prevAll().children('i').removeClass("active");
								$(this).nextAll().children('i').removeClass("active");
								$(this).children('i').addClass("active");
								var good = $(this).text();
								if( good == '好评'){
									$(this).siblings('.good').val('好评');
								}
								else if( good == '中评'){
									$(this).siblings('.good').val('中评');
								}
								else{
									$(this).siblings('.good').val('差评');
								}
							});
				     })
					</script>					
					
												
							
						</div>

					</div>

				</div>
				<!--底部-->
				<include file="./Application/Home/View/Share/footer.html" />
			</div>

			<aside class="menu">
				<include file="./Application/Home/View/Share/menu.html" />

			</aside>
		</div>

	</body>
	


<!-- 引用核心层插件 -->
<script type="text/javascript" src="/Public/tools/php_img_upload/core/zyFile.js"></script>
<!-- 引用控制层插件 -->
<script type="text/javascript" src="/Public/tools/php_img_upload/control/js/zyUpload.js"></script>

<script>
function getprogram(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
} 
var order_id = getprogram('order_id');

function commentbtn(obj){
	var ware_id	= $(obj).prev().val();
	var good	= $(obj).parents('.info-btn').prev().find('.good').val();
	var content	= $(obj).parents('.info-btn').siblings('.item-comment').find('.content').val();
	var id		= $(obj).siblings('.id').val();
	
	$.post('/Api/comment/commentbtn' , { id:id , ware_id:ware_id , good:good , content:content , order_id:order_id} , function(ret){
		if( ret.status == true){
			alert(ret.data);
			window.location.href="";
		}
		else{
			alert(ret.data);
		}
	});
	
}

function modal(obj){
	var shopcarid = $(obj).val();
	
	$(obj).siblings('#doc-modal-1').modal("open");
	var ware_id = $(obj).siblings('#doc-modal-1').find('.phwareid').val();
	shopcar_id = shopcarid;
	
	$(function(){
		// 初始化插件
		var width = $(window).width();
		if ( width >= 650 )	 width = '750px';
		else 	width = "100%";

		$("#demo").zyUpload({
			width            :   width,                 // 宽度
			height           :   "auto",                 // 宽度
			itemWidth        :   "140px",                 // 文件项的宽度
			itemHeight       :   "100px",                 // 文件项的高度
			//url              :   "/upload/UploadAction",  // 上传文件的路径
			url              :   "/Api/Comment/imgUpload?id="+shopcar_id,
			inputName		 : 	'_img',
			id 				 :	 1,
			multiple         :   true,                    // 是否可以多个文件上传
			dragDrop         :   false,                    // 是否可以拖动上传文件
			del              :   true,                    // 是否可以删除文件
			finishDel        :   false,  				  // 是否在上传文件完成后删除预览
			/* 外部获得的回调接口 */
			onSelect: function(selectFiles, allFiles){    // 选择文件的回调方法  selectFile:当前选中的文件  allFiles:还没上传的全部文件
				console.info("当前选择了以下文件：");
				console.info(selectFiles);
			},
			onProgress: function(file, loaded, total){    // 正在上传的进度的回调方法
				var eleProgress = $("#uploadProgress_" + file.index), percent = (loaded / total * 100).toFixed(2) + '%';
				eleProgress.html(percent);
				console.info(file.index);
				console.info("当前正在上传此文件：");
				console.info(file.name);
				console.info("进度等信息如下：");
				console.info(loaded);
				console.info(total);
			},   
			onDelete: function(file, files){              // 删除一个文件的回调方法 file:当前删除的文件  files:删除之后的文件
				console.info("当前删除了此文件：");
				console.info(file.name);
			},
			onSuccess: function(file, response){          // 文件上传成功的回调方法
				console.info("此文件上传成功：");
				$('#successinfo').append("<p>"+response+"</p>");
				console.info(response);
				$(obj).siblings('#doc-modal-1').modal("close");
			},
			onFailure: function(file, response){          // 文件上传失败的回调方法
				$("#uploadImage_" + file.index).css("opacity", 0.2);
				console.info("此文件上传失败：");
				console.info(file.name);
			},
			onComplete: function(response){           	  // 上传完成的回调方法
				console.info("文件上传完成");
				console.info(response);
				
			}
		});
	
	});	
}



</script>
</html>
